<template>
  <div class="title-bar" :style="componentStyle">
    <h4>{{ text }}</h4>
  </div>
</template>

<script>
export default {
  name: 'TitleBar',
  props: {
    text: {
      type: String,
      default: '标题栏'
    },
    color: {
      type: String,
      default: '#333333'
    },
    fontSize: {
      type: Number,
      default: 16
    },
    textAlign: {
      type: String,
      default: 'center'
    }
  },
  computed: {
    componentStyle() {
      return {
        color: this.color,
        fontSize: `${this.fontSize}px`,
        textAlign: this.textAlign
      };
    }
  }
}
</script>

<style scoped>
.title-bar {
  padding: 10px;
  background-color: #f7f7f7;
}
h4 {
  margin: 0;
}
</style>